import java.util.ArrayList;


public class Vertex {
	private String id;
	
	private ArrayList<Edge> inEdges;
	private ArrayList<Edge> outEdges;
	
	//private ArrayList<T> vehiclesHere;
	
	public Vertex(String id) {
		this.id = id;
		
		this.inEdges = new ArrayList<Edge>();
		this.outEdges = new ArrayList<Edge>();
		
		//this.vehiclesHere = new ArrayList<T>();
	}
	
	public void addInEdge(Edge e) {
		this.inEdges.add(e);
	}
	
	public void addOutEdge(Edge e) {
		this.outEdges.add(e);
	}
	
	public ArrayList<Edge> getInEdges() {
		return inEdges;
	}

	public ArrayList<Edge> getOutEdges() {
		return outEdges;
	}
	
	public ArrayList<Vertex> getNeighbours() {
		ArrayList<Vertex> N = new ArrayList<Vertex>();
		for (Edge e : inEdges) {
			if (e.getFrom() != this)
				N.add(e.getFrom());
		}
		for (Edge e : outEdges) {
			if (e.getTo() != this)
				if (!N.contains(e.getTo()))
					N.add(e.getTo());
		}
		return N;
	}
	
	public String getId() {
		return id;
	}

	public String toString() {
		return id;
	}

	public void removeEdgesWith(Vertex v) {
		Edge toRem = null;
		for (Edge e : inEdges) {
			if (e.getFrom().equals(v)) {
				toRem = e;
				break;
			}
		}
		inEdges.remove(toRem);
		
		toRem = null;
		for (Edge e : outEdges) {
			if (e.getFrom().equals(v)) {
				toRem = e;
				break;
			}
		}
		outEdges.remove(toRem);
	}
}
